
local CGUniforms = CGUniforms or {}
CGUniforms.__index = CGUniforms

function CGUniforms.new()
    local self = setmetatable({}, CGUniforms)
    self.inputs = {}
    self.nexts = {}
    self.Uniforms = {}
    return self
end

function CGUniforms:setInput(index, func)
    self.inputs[index] = func
end

function CGUniforms:setNext(index, func)
    self.nexts[index] = func
end

function CGUniforms:getOutput(index)
    return self.Uniforms
end

function CGUniforms:execute(index)
    self.Uniforms[0] = self.inputs[0]() or nil
    self.Uniforms[1] = self.inputs[1]() or nil
    self.Uniforms[2] = self.inputs[2]() or nil
    self.Uniforms[3] = self.inputs[3]() or nil
    self.Uniforms[4] = self.inputs[4]() or nil
    self.Uniforms[5] = self.inputs[5]() or nil
    self.Uniforms[6] = self.inputs[6]() or nil
    self.Uniforms[7] = self.inputs[7]() or nil
    if self.nexts[0] ~= nil then
        self.nexts[0]()
    end
end

function CGUniforms:update(sys, deltaTime)
    self.Uniforms[0] = self.inputs[0]() or nil
    self.Uniforms[1] = self.inputs[1]() or nil
    self.Uniforms[2] = self.inputs[2]() or nil
    self.Uniforms[3] = self.inputs[3]() or nil
    self.Uniforms[4] = self.inputs[4]() or nil
    self.Uniforms[5] = self.inputs[5]() or nil
    self.Uniforms[6] = self.inputs[6]() or nil
    self.Uniforms[7] = self.inputs[7]() or nil
    if self.nexts[0] ~= nil then
        self.nexts[0]()
    end
end

return CGUniforms